package com.bdqn.t320.ch13.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bdqn.t320.ch13.entity.Role;
import com.bdqn.t320.ch13.mapper.RoleMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RoleServiceImp extends ServiceImpl<RoleMapper, Role> implements RoleService {

    @Resource
    RoleMapper roleMapper;

    @Override
    public String getRoleNameByRoleIdBiz(Long roleId) {
        QueryWrapper<Role> queryWrapper = new QueryWrapper();
        queryWrapper.eq("role_id", roleId);
        Role role = roleMapper.selectOne(queryWrapper);
        return role.getRoleName();
    }

    @Override
    public List<Role> getRoleListBiz() {
        QueryWrapper<Role> queryWrapper = new QueryWrapper();
        queryWrapper.orderByAsc("role_id");
        return roleMapper.selectList(queryWrapper);
    }
}
